<#assign base=request.contextPath />
<!DOCTYPE html>
<div class="row">
	<div class="col-md-12 col-sm-12 col-xs-12">
		<div class="x_panel">
			<div class="x_title">
				<h2>农户审核 <small></small></h2>
				<div class="clearfix"></div>
			</div>
			<div class="x_content">
				<br/>
				<form id="postForm" data-parsley-validate class="form-horizontal form-label-left" method="post" action="${base}/gx/user/doCheck">
					<input type="hidden" id="id" name="id" value="${((obj.id)?c)!0 }">
					<input type="hidden" name="userType" value="${(obj.userType)!userType}">
		            <input type="hidden" name="updateTime" value="${.now?string['yyyy-MM-dd HH:mm:ss']}">
		            <input type="hidden" name="updator" value="${(obj.updator)!admin.userName}">
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">所属省 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<select id="province" class="form-control select2">
                        		<option value="">请选择</option>
	                        	<#list listProvince as province>
	                        	<option value="${province.code}" <#if (obj.areaProvince.code==province.code)>selected="selected"</#if>>${province.cityName}</option>
	                        	</#list>
	                    	</select>
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">所属市 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<select id="city" class="form-control select2">
                        		<option value="">请选择</option>
	                        	<#list listCity as city>
	                        	<option value="${city.code}" <#if (obj.areaCity.code==city.code)>selected="selected"</#if>>${city.cityName}</option>
	                        	</#list>
	                    	</select>
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">所属区县<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<select id="district" class="form-control select2">
                        		<option value="">请选择</option>
	                        	<#list listDistrict as district>
	                        	<option value="${district.code}" <#if (obj.areaDistrict.code==district.code)>selected="selected"</#if>>${district.cityName}</option>
	                        	</#list>
	                    	</select>
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">所属业务员 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<select id="belongId" class="form-control select2">
                        		<option value="">请选择</option>
	                        	<#list listYWY as ywy>
	                        	<option value="${ywy.id}" <#if (obj.belongId==ywy.id)>selected="selected"</#if>>${ywy.userName}</option>
	                        	</#list>
	                    	</select>
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">地址 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="address" value="${(obj.address)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">地址经度 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="lon" value="${(obj.lon)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">地址纬度 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="lat" value="${(obj.lat)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">用户名 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="userName" value="${(obj.userName)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">密码 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="password" id="password" value="${(obj.password)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">手机号 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="phone" value="${(obj.phone)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">身份证号 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="cardNo" value="${(obj.cardNo)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">真实姓名 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="realName" value="${(obj.realName)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">性别 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	男：<input type="radio" class="flat" value="男" <#if (obj.sex=='男')>checked="checked"</#if>/>&nbsp;
                        	女：<input type="radio" class="flat" value="女" <#if (obj.sex=='女')>checked="checked"</#if>/>
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">生日 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="birth" value="${(obj.birth)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">年龄 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="age" value="${(obj.age)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">户口本号 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="regNo" value="${(obj.regNo)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">户主 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="regMain" value="${(obj.regMain)!''}" class="form-control col-md-7 col-xs-12" readonly="readonly">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">身份证图片 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="file" id="cardIcon_dropify" name="file1" class="dropify" data-default-file="${imagePath}${(obj.cardIcon)!''}" />
                            <input type="hidden" name="cardIcon" id="cardIcon" value="${(obj.cardIcon)!''}">
                            <input type="hidden" name="cardIconOld" id="cardIconOld" value="${(obj.cardIcon)!''}">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">户口本图片 <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="file" id="regIcon_dropify" name="file2" class="dropify" data-default-file="${imagePath}${(obj.regIcon)!''}" />
                            <input type="hidden" name="regIcon" id="regIcon" value="${(obj.regIcon)!''}">
                            <input type="hidden" name="regIconOld" id="regIconOld" value="${(obj.regIcon)!''}">
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">审核结果<span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	通过：<input type="radio" class="flat" name="isChecked" value="1" <#if (obj.isChecked==1)>checked="checked"</#if>/>&nbsp;
                        	不通过：<input type="radio" class="flat" name="isChecked" value="0" <#if (obj.isChecked==0)>checked="checked"</#if>/>
                        </div>
					</div>
					<div class="form-group">
						<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">审核备注 <span class="required"></span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                        	<input type="text" id="checkRemark" name="checkRemark" value="${(obj.checkRemark)!''}" class="form-control col-md-7 col-xs-12">
                        </div>
					</div>
					<div class="ln_solid"></div>
					<div class="form-group">
						<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
							<button type="button" class="btn btn-success" id="submit">保存</button>
							<button type="button" class="btn btn-primary" id="goBack">返回</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
$(function() {
	//iCheck
	if ($("input.flat")[0]) {
		$(document).ready(function () {
	    	$('input.flat').iCheck({
	        	checkboxClass: 'icheckbox_flat-green',
	        	radioClass: 'iradio_flat-green'
	        });
	    });
	}
	// /iCheck
	laydate.render({elem: '#birth',type: 'date'});
	//select2
	$(".select2").select2({width: "100%"});
	$("#province").change(function(){
		$.post("${base}/common/getAreaList", {"pCode":$(this).val()}, function(data) {
			if (data.flag) {
				$("#city").empty();
				$("#city").append("<option value=''>请选择</option>");
				$.each(data.obj, function(i, n){
					$("#city").append("<option value='"+n.code+"'>"+n.cityName+"</option>");
				});
			}
		});
	});
	$("#city").change(function(){
		$.post("${base}/common/getAreaList", {"pCode":$(this).val()}, function(data) {
			if (data.flag) {
				$("#district").empty();
				$("#district").append("<option value=''>请选择</option>");
				$.each(data.obj, function(i, n){
					$("#district").append("<option value='"+n.code+"'>"+n.cityName+"</option>");
				});
			}
		});
	});
	$("#belongDLS").change(function(){
		$.post("${base}/common/getYYBList", {"pId":$(this).val()}, function(data) {
			if (data.flag) {
				$("#belongId").empty();
				$("#belongId").append("<option value=''>请选择</option>");
				$.each(data.obj, function(i, n){
					$("#belongId").append("<option value='"+n.id+"'>"+n.userName+"</option>");
				});
			}
		});
	});
	 $('.dropify').dropify({
     	messages: {
		        'default': '点击或拖拽文件到这里',
		        'replace': '点击或拖拽文件到这里来替换文件',
		        'remove':  '移除文件',
		        'error':   '对不起，你上传的文件太大了',
		    }
     });
     // Used events
     drEvent = $('#cardIcon_dropify').dropify();
     drEvent.on('dropify.afterClear', function(event, element) {
     	$("#cardIcon").val("");
     });

     drEvent.on('dropify.errors', function(event, element) {
         console.log('Has Errors');
     });
     
     drEvent2 = $('#regIcon_dropify').dropify();
     drEvent2.on('dropify.afterClear', function(event, element) {
     	$("#regIcon").val("");
     });

     drEvent2.on('dropify.errors', function(event, element) {
         console.log('Has Errors');
     });

	$("#goBack").click(function() {
		$("#main_content").load('${base}/gx/user/list',{"userType":'${userType}'});	        
    });
	
	$("#submit").click(function() {
        $("#postForm").ajaxSubmit(function(data) {
    	 	if (data.flag) {
    	 		swal(data.msg, "", "success");
				$("#main_content").load('${base}/gx/user/list',{"userType":'${userType}'});
    	 	} 
    	 	else {
    	 		swal(data.msg, "", "error");
    	 	}
    	});
	});
});
</script>